<script type="text/javascript">
	var root_path = '<?php echo _SITE_ADMIN_URL_?>';
	var table = 'city_master';
	var field = 'name';
	
	$(document).ready(function(){
		$('#country').change(function(){
			var country = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+country+'&type=state';
			$.ajax({url: path,	
				success: function(response) {
					$('#state').html(response);
				}
			});
			
		});
		$('#state').change(function(){
			var country = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+country+'&type=city';
			$.ajax({url: path,	
				success: function(response) {
					$('#city').html(response);
				}
			});
			
		});
	});

	jQuery.validator.addMethod(
		"selectCountryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a country."
	);
	
	jQuery.validator.addMethod(
		"selectStateNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a state."
	);
	
	$().ready(function() {
		$("#adminForm").validate({
			rules: {
				country_id: {
					selectCountryNone: true
				},
				state_id: {
					selectStateNone: true
				},
				name: "required"
			 },
			messages: {
				name: "Please enter city name",
			}
		});
		
		
	});
</script>  
<!-- Example table -->
<div class="container_12"> 
    <div class="module">
        <h2><span><?php echo $_title; ?></span></h2>
        <div class="module-body">
            <div style="margin-top:13px;">
                <?php
                if(isset($errMsg)){?>
                    <span class="notification"><?php echo $_MESSESGE[$errMsg];?></span>
                <?php }?>
			</div>
                        
            <form id="adminForm" name="admin_frm" action="" method="post" enctype="multipart/form-data">
				<p>
					<label>Country</label>
					<select class="input-short" id="country" name="country_id">
						<?php echo $dropdown_countries; ?>
					</select>
				</p>
				<p>
					<label>State</label>
					<select class="input-short" id="state" name="state_id">
						<option value="">Select State</option>
					</select>
				</p>
				<p>
					<label>City</label>
					<div id="availability_info"></div>
					<input type="text" class="input-short check_availability" name="name" value="<?php echo $_POST['name'];?>" />
					<!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
				</p>  
				<fieldset>
					<input class="submit-green" type="submit" name="submit" value="Submit" /> 
				   <input class="submit-gray" type="button" value="Cancel" onclick="javascript: window.location='<?php echo _SITE_ADMIN_URL_?>'+'category/category_mng.php';" />
				</fieldset>
			</form>
		</div> <!-- End .module-body -->
	</div>  <!-- End .module -->
</div>
<div style="clear:both;"></div>
<script type="text/javascript" src="<?php echo _ADMIN_JS_; ?>check_availability.js"></script>